<template>
    <el-dialog :visible.sync="visible" v-dialogDrag :title="title" class="tl-dialog" width="1200px" @open="open" @close="close" top="10px" :append-to-body="true" :modal-append-to-body="true">
        <div style="padding-bottom:10px">
            <!-- 查询界面 -->
            <tl-list-search ref="search" :query-param="queryParam" @search="doQuery" :isDisplayDefaultSearch="false" v-if="isHeaderDisplay">
                <template slot="search">
                    <el-form-item label="任务名称" prop="code">
                        <el-input v-model="queryParam.qry_name" placeholder=""></el-input>
                    </el-form-item>
                    <el-form-item label="负责人">
                        <el-input v-model="queryParam.qry_leadername" placeholder=""></el-input>
                    </el-form-item>
                </template>
            </tl-list-search>
            <!-- 列表界面 -->
            <div>
                <!-- 列表选择 -->
                <div class="table-alert-div" ref="selector">
                    <el-alert type="success" :closable="false" class="tl-table-alert-info" effect="light">
                        <template slot="title">
                            已选择&nbsp;<a class="tl-table-alert-info-a1">{{ selectedRows.length }}</a>项&nbsp;&nbsp;
                            <a class="tl-table-alert-info-a2" @click="doClearSelected">全部清空</a>
                        </template>
                    </el-alert>
                </div>
                <!--表格渲染-->
                <el-table class="tl-table" ref="mainTable" :height="tableHeight" v-loading="loading" :data="datas" @selection-change="doSelectChange" @sort-change="doSortChange" @row-dblclick="doRowDbClick" row-key="id" border fit :row-class-name="doChangeRowClassName">
                    <el-table-column type="selection" width="55px" fixed="left" v-if="isSingleSelect === false "> </el-table-column>
                    <el-table-column prop="name" label="任务名称" width="200px" sortable="custom" sort-by="name" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
                    <el-table-column prop="dispmilepostid" label="里程碑" width="150px" sortable="custom" sort-by="milepostid" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
                    <el-table-column prop="dispprojectid" label="项目" width="200px" sortable="custom" sort-by="projectid" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
                    <el-table-column prop="disptaskstate" label="任务状态" width="100px" sortable="custom" sort-by="taskstate" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
                    <el-table-column prop="leadername" label="负责人" width="80px" sortable="custom" sort-by="leadername" align="center" :show-overflow-tooltip="true"></el-table-column>
                    <el-table-column prop="leadercode" label="负责人工号" width="100px" sortable="custom" sort-by="leadercode" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
                    <el-table-column prop="participantnames" label="参与人" width="200px" sortable="custom" sort-by="participantnames" align="left" :show-overflow-tooltip="true"></el-table-column>
                    <!-- <el-table-column prop="participantcodes" label="参与人工号" width="200px" sortable="custom" sort-by="participantcodes" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column> -->
                    <el-table-column prop="latestphase" label="最新阶段" width="100px" sortable="custom" sort-by="latestphase" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
                    <el-table-column prop="disptasktype" label="任务类型" width="100px" sortable="custom" sort-by="tasktype" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
                    <el-table-column prop="disptaskcategory" label="任务类别" width="100px" sortable="custom" sort-by="taskcategory" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
                    <el-table-column prop="disppriority" label="优先级" width="100px" sortable="custom" sort-by="priority" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
                    <el-table-column prop="progress" label="自评进度" width="100px" sortable="custom" sort-by="progress" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
                    <el-table-column prop="progressexplain" label="进度说明" width="200px" sortable="custom" sort-by="progressexplain" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
                    <el-table-column prop="progressscore" label="任务进度评分" width="120px" sortable="custom" sort-by="progressscore" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
                    <el-table-column prop="qualityscore" label="任务质量评分" width="120px" sortable="custom" sort-by="qualityscore" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
                    <!-- <el-table-column prop="noticecodes" label="日志通知人工号" width="150px" sortable="custom" sort-by="noticecodes" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
                <el-table-column prop="noticename" label="日志通知人" width="120px" sortable="custom" sort-by="noticename" align="center" :show-overflow-tooltip="true"></el-table-column> -->
                    <el-table-column prop="explain" label="任务说明" width="200px" sortable="custom" sort-by="explain" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
                    <el-table-column prop="starttime" label="计划开始日期" width="120px" sortable="custom" sort-by="starttime" align="center" header-align="center" :formatter="dateFormat" :show-overflow-tooltip="true"></el-table-column>
                    <el-table-column prop="endtime" label="计划结束日期" width="120px" sortable="custom" sort-by="endtime" align="center" header-align="center" :formatter="dateFormat" :show-overflow-tooltip="true"></el-table-column>
                    <el-table-column prop="actualstarttime" label="实际开始日期" width="120px" sortable="custom" sort-by="actualstarttime" align="center" header-align="center" :formatter="dateFormat" :show-overflow-tooltip="true"></el-table-column>
                    <el-table-column prop="actualendtime" label="实际结束日期" width="120px" sortable="custom" sort-by="actualendtime" align="center" header-align="center" :formatter="dateFormat" :show-overflow-tooltip="true"></el-table-column>
                    <el-table-column prop="canceltime" label="任务取消日期" width="120px" sortable="custom" sort-by="canceltime" align="center" header-align="center" :formatter="dateFormat" :show-overflow-tooltip="true"></el-table-column>
                    <el-table-column prop="cancelreason" label="任务取消原因" width="200px" sortable="custom" sort-by="cancelreason" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
                    <!-- <el-table-column prop="orgname" label="派工公司" width="200px" sortable="custom" sort-by="orgname" align="left" :show-overflow-tooltip="true"></el-table-column>
                <el-table-column prop="orgcode" label="公司编码" width="100px" sortable="custom" sort-by="orgcode" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column> -->
                    <el-table-column prop="deptname" label="派工部门" width="200px" sortable="custom" sort-by="deptname" align="left" :show-overflow-tooltip="true"></el-table-column>
                    <el-table-column prop="deptcode" label="派工部门编码" width="120px" sortable="custom" sort-by="deptcode" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
                    <el-table-column prop="usercode" label="派工人工号" width="100px" sortable="custom" sort-by="usercode" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
                    <el-table-column prop="username" label="派工人" width="80px" sortable="custom" sort-by="username" align="center" :show-overflow-tooltip="true"></el-table-column>
                    <el-table-column prop="docdate" label="单据日期" width="100px" sortable="custom" sort-by="docdate" align="center" header-align="center" :formatter="dateFormat" :show-overflow-tooltip="true"></el-table-column>
                    <el-table-column prop="submitdate" label="提交时间" width="200px" sortable="custom" sort-by="submitdate" align="center" header-align="center" :formatter="dateTimeFormat" :show-overflow-tooltip="true"></el-table-column>
                    <el-table-column prop="docno" label="单据编号" width="120px" sortable="custom" sort-by="docno" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
                    <el-table-column prop="dispflowid" label="审批流程" width="120px" sortable="custom" sort-by="flowid" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
                    <el-table-column prop="dispstate" label="状态" width="80px" sortable="custom" sort-by="state" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
                    <el-table-column prop="description" label="备注" min-width="200px" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
                    <el-table-column label="操作" width="80px" align="center" fixed="right" v-if="isSingleSelect === true">
                        <template slot-scope="scope">
                            <el-button type="text" icon="el-icon-finished" @click="doSelectData(scope.row[fieldDefaultKey])">选择</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <!-- 列表分页 -->
                <el-row class="pagebar" ref="pager">
                    <el-pagination @size-change="doChangeSize" @current-change="doChangeIndex" :current-page="pageInfo.currentPage" :page-sizes="pageInfo.pageSizes" :total="pageInfo.totalCount" layout="total, sizes, prev, pager, next, jumper" background class="tl-table-pagination"> </el-pagination>
                </el-row>
            </div>
        </div>
        <div slot="footer" class="dialog-footer" v-if="isSingleSelect === false">
            <el-button type="text" @click="doCancelEdit">取消</el-button>
            <el-button type="primary" @click="doConfirm">确认</el-button>
        </div>
    </el-dialog>
</template>

<script>
/** mixins */
import { mixin_ref_list } from '@tapui/mixins/mixin_ref_list'
/** 子组件 */
/** 工具类 */
import { queryDataCode } from '@tapui/api/dataCode'
import { getAction, putAction, postAction } from '@tapui/utils/http'
/** VUE配置 */
export default {
    name: 'TlPmTaskRef',
    components: {},
    mixins: [mixin_ref_list],
    data() {
        return {
            description: '任务管理参照页面',
            // 默认Key字段名
            fieldDefaultKey: 'id',
            // 默认显示字段名
            fieldDefaultValue: 'name',
            // url配置
            url: {
                list: '/pm/task/refList'
            },
            // 排序参数
            sorterInfo: {
                sidx: 'sortcode',
                sord: 'asc'
            }
        }
    },
    props: {
        isHeaderDisplay: {
            default: true,
            type: Boolean
        },
        isDisplayDefaultElement: {
            default: true,
            type: Boolean
        },
        width: {
            default: "",
            type: String
        },
        initDisplayData: {
            default: "",
            type: String
        }
    },
    methods: {}
}
</script>

